var app = angular.module('app',[]);

app.factory('LectureList',function($scope, $http){
	return{list: [
		{id:0,
		 name:"Lecture 1",
		 link:"http://www.youtube.com/embed/uYZy9eRazVw",
		 comments: ["hello","ja","saell"]
		},{
		 id:1,
		 name: "Lecture 2",
		 link: "http://www.youtube.com/embed/rrOuJY3G5fU",
		 comments: ["va","shitt thetta er langt comment, veit ekki hvort thad virki en samt va...!!!!"]
		}
		]};
		
});

app.config(function($routeProvider){
	$routeProvider
		.when('/',
		{ templateUrl:"lectures.html",controller: "LecturesController"})
		.when('/lecture/:id',
		{ templateUrl:"lecture.html",controller: "LectureController"})
		.otherwise(
			{template: "End of the multiverse!!!!"})
		;
});


app.controller('LecturesController',["$location","$http",'$scope',function ($location,$http,$scope){
	$http.get("http://localhost:49702/api/lectures").success(function(data,status){
			console.log("asdf");
		});
	
}]);

app.controller('LectureController',['$scope','$http','$routeParams',function ($scope,$http,$routeParams){
		console.log($routeParams.id)
		var lecture;
		$http.get("localhost:49702/api/lectures").then(function(resp){
			console.log(resp.data);
		});
		/*for (var i = 0; i<LectureList.list.length;i++){
			if (LectureList.list[i].id == $routeParams.id){
				lecture = LectureList.list[i];
				break;
			}
		}*/
		//$scope.lecture = lecture;
}]);
